package com.simplefan.meta;

import java.io.Serializable;
import java.util.List;

/**
 * @author simplefan
 */
public interface MetaClass extends Serializable {

  /**
   * Corresponding of XM_ENTITYSPEC.CODE in database.
   * @return
   */
  String getCode();

  /**
   * Corresponding of XM_ENTITYSPEC.DISPLAYNAME in database.
   * @return
   */
  String getDisplayName();

  /**
   * Corresponding of XM_ENTITYSPEC.CLASSNAME in database.
   * @return
   */
  String getClassName();

  /**
   * Class name of its inherited MetaClass.
   * @return
   */
  String getParentClassName();

  /**
   * All attribute of MetaClass.
   * @return
   */
  List<MetaAttribute> getMetaAttributes();

  /**
   * Inherited MetaClass
   * @return
   */
  MetaClass getParentMetaClass();

  /**
   * If a MetaObject is an instance of this MetaClass. like "instance of" in java. 
   * @param object
   * @return
   */
  boolean isInstance(MetaObject mo);

  /**
   * Relationships between this MetaClass and another MetaClass. 
   * @return
   */
  List<MetaClassRelation> getMetaClassRelations();

  /**
   * Relationships between this MetaClass and its MetaComponent. 
   * @return
   */
  List<MetaComponentRelation> getMetaComponentRelations();

  /**
   * Find MetaAttribute by attribute's name. 
   * @return
   */
  MetaAttribute findMetaAttribute(String key);

  /**
   * Find MetaComponentRelation by MetaComponent's name. 
   * @return
   */
  MetaComponentRelation findMetaComponentRelation(String componentName);

  /**
   * Find MetaClassRelation by MetaClassRelation's code.
   * @return
   */
  MetaClassRelation findMetaClassRelation(String code);

  /**
   * Corresponding of XM_ENTITYSPEC.ID in database.
   * @return
   */
  long getId();

  MetaAttribute getPrimitiveAttribute();

  List<MetaClass> getChildren();

  /**
   * Corresponding of XM_ENTITYSPEC.VERSIONINSTANCE in database.
   * @return
   */
  long getVersionInstanceId();
}
